package com.dldata.devtools30.repository.zhibiao;



import com.dldata.devtools30.entity.DevtZbcfgInfoEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by ai on 2017/1/11.
 */
@Repository
public interface DevtZbcfgInfoEntityDao
        extends com.dldata.devtools30.repository.BaseRepository<DevtZbcfgInfoEntity,String>, JpaSpecificationExecutor<DevtZbcfgInfoEntity> {
    
    @Query("select t from DevtZbcfgInfoEntity t order by xh ")
    public List<DevtZbcfgInfoEntity> getAll();
    
    @Query("select t from DevtZbcfgInfoEntity t where t.zbname like  ?1 or zbcode like ?1 and delflag=0 order by xh ")
    public List<DevtZbcfgInfoEntity> getAll(String serach);
    
    @Query("select t from DevtZbcfgInfoEntity t where t.zbclassid = ?1  and delflag=0 order by xh ")
    public List<DevtZbcfgInfoEntity> getAllByClassId(String zbcalssId);
    
    @Query("select t from DevtZbcfgInfoEntity t where t.zbclassid = ?1  and (t.zbname like  ?2 or zbcode like ?2) and delflag=0 order by xh ")
    public List<DevtZbcfgInfoEntity> getAllByClassId(String zbcalssId,String serach);
    
    @Query("select max(t.xh) xh from DevtZbcfgInfoEntity t ")
    public Integer getMaxXh();
    
    @Query("select t from DevtZbcfgInfoEntity t where t.id in ( select O.planzbid from DevtZbplanItemEntity O where O.planid = ?1  )  order by xh ")
    public List<DevtZbcfgInfoEntity> getAllByPlanId(String planId);
    
    @Query("select t from DevtZbcfgInfoEntity t where t.id not in ( select O.planzbid from DevtZbplanItemEntity O where O.planid = ?1  )  and delflag=0 order by xh ")
    public List<DevtZbcfgInfoEntity> getAllByNotPlanId(String planId);
    
}
